﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
using Windows.UI.Xaml;
using Windows.UI.Xaml.Data;

namespace CC98.Xaml.Converters
{
    public class ParallaxConverter : FrameworkElement, IValueConverter
    {
        public double VisualWidth
        {
            get { return (double)GetValue(VisualWidthProperty); }
            set { SetValue(VisualWidthProperty, value); }
        }
        public static readonly DependencyProperty VisualWidthProperty =
            DependencyProperty.Register("VisualWidth", typeof(double), typeof(ParallaxConverter), new PropertyMetadata(0.0));

        public double ImageWidth
        {
            get { return (double)GetValue(ImageWidthProperty); }
            set { SetValue(ImageWidthProperty, value); }
        }
        public static readonly DependencyProperty ImageWidthProperty =
            DependencyProperty.Register("ImageWidth", typeof(double), typeof(ParallaxConverter), new PropertyMetadata(0.0));

        public object Convert(object value, Type targetType, object parameter, string language)
        {
            var offset = (double)value;

            return -offset / 7;
        }

        public object ConvertBack(object value, Type targetType, object parameter, string language)
        {
            throw new NotImplementedException();
        }
    }
}
